//
//  DFGridView.h
//  汽车人之家
//
//  Created by HZ on 14-9-30.
//  Copyright (c) 2014年 cn.huiz.gang12. All rights reserved.
//

#import <UIKit/UIKit.h>

@class DFGridView;
@class DFGridViewIndexPath;


@protocol DFGridViewDataSource <NSObject>


@required

- (NSInteger)numberOfItemsInGridView:(DFGridView*)gridView;

- (NSInteger)numberOfColumnsInGridView:(DFGridView*)gridView;

- (void)gridView:(DFGridView*)gridView viewForItem:(UIView*)item atIndexPath:(DFGridViewIndexPath*)indexPath;

@end


@interface DFGridViewIndexPath : NSObject


@property (nonatomic) NSInteger column;
@property (nonatomic) NSInteger row;
@property (nonatomic) NSInteger index;

-(instancetype)initWithIndex:(NSInteger)index row:(NSInteger)row column:(NSInteger)column;

+ (instancetype)indexPathWithIndex:(NSInteger)index row:(NSInteger)row column:(NSInteger)column;

@end


@interface DFGridView : UIView

@property (nonatomic,weak) IBOutlet id<DFGridViewDataSource> dataSource;
@property (nonatomic,readonly) NSArray* items;

-(DFGridViewIndexPath*)indexPathWithItem:(UIView*)item;

- (void)reloadData;
@end
